package PublishSubscribe;

import Utils.ConnectionFactoryUtil;
import com.rabbitmq.client.*;

import java.io.IOException;
import java.util.concurrent.TimeoutException;

/**
 * @ClassName ConsumerStation
 * @Description TDD
 * @Author 混沌酱
 * @Date 2023-10-10 14:45
 * @Version 1.0
 **/
public class ConsumerStation {

    public static void main(String[] args) throws IOException, TimeoutException {
        Connection connection= ConnectionFactoryUtil.getConnection();
        Channel channel=connection.createChannel();

        channel.basicConsume("SEND_STATION",true, new DefaultConsumer(channel){
            @Override
            public void handleDelivery(String consumerTag, Envelope envelope, AMQP.BasicProperties properties, byte[] body) throws IOException {
                super.handleDelivery(consumerTag, envelope, properties, body);
                String message=new String(body,"UTF-8");
                System.out.println(message);
            }
        });

    }
}
